import java.net.URL;
import java.util.Stack;

public class History {
	Stack<URL> back;
	Stack<URL> forward;

	public History() {
		back = new Stack<>();
		forward = new Stack<>();
	}

	public void add(URL currentWebPage) {
		forward.clear();
		back.push(currentWebPage);
	}

	public void hitBackButton() {
		URL oldCurrent = back.pop();
		forward.push(oldCurrent);
	}

	public void hitForwardButton() {
		URL newCurrent = forward.pop();
		back.push(newCurrent);
	}

	public URL getCurrentURL() {
		return back.peek();
	}

	public int backSize() {
		return back.size();
	}
}
